package online.hxstart.code.concurrent.chapter06;

import java.util.concurrent.TimeUnit;

/**
 * @author huxing
 * @date 19-5-31 星期五 下午6:16
 * @describe
 */
public class ThreadGroupDaemon {

  public static void main(String[] args) throws InterruptedException {
    //

    ThreadGroup group1 = new ThreadGroup("Group1");

    new Thread(group1, () -> {
      try {
        TimeUnit.SECONDS.sleep(1);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }, "group-myThread").start();

    ThreadGroup group2 = new ThreadGroup("Group2");
    new Thread(group2, () -> {
      try {
        TimeUnit.SECONDS.sleep(1);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }, "group2-myThread").start();

    group2.setDaemon(true);

    TimeUnit.SECONDS.sleep(3);

    System.out.println(group1.isDestroyed());
    System.out.println(group2.isDestroyed());
  }
}
